import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/login',
    },
    {
      name: 'login',
      path: '/login',
      component: () => import('@/page/Login.vue'),
    },
    {
      name: 'home',
      path: '/home',
      component: () => import('@/page/Home.vue'),
      children: [
        {
          name: 'user',
          path: 'user', //路径不能以/开头
          component: () => import('@/page/User.vue'),
        },
        {
          name: 'userDetail',
          path: 'user/:id', //路径不能以/开头
          component: () => import('@/page/UserDetail.vue'),
        },
        {
          name: 'marketActivity',
          path: 'market-activity', //路径不能以/开头
          component: () => import('@/page/MarketActivity.vue'),
        },
        {
          name: 'marketActivityAdd',
          path: 'market-activity-add', //路径不能以/开头
          component: () => import('@/page/MarketActivityAdd.vue'),
        },
        {
          name: 'marketActivityEdit',
          path: 'market-activity-edit/:id', //路径不能以/开头
          component: () => import('@/page/MarketActivityAdd.vue'),
        },
        {
          name: 'marketActivityDetail',
          path: 'market-activity-detail/:id', //路径不能以/开头
          component: () => import('@/page/MarketActivityDetail.vue'),
        },
        {
          name: 'clue',
          path: 'clue', //路径不能以/开头
          component: () => import('@/page/Clue.vue'),
        },
        {
          name: 'customer',
          path: 'customer', //路径不能以/开头
          component: () => import('@/page/Customer.vue'),
        },
      ],
    },
  ],
})

export default router
